package com.kuang.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.lang.Nullable;
import org.springframework.web.servlet.LocaleResolver;
import org.springframework.web.servlet.View;
import org.springframework.web.servlet.ViewResolver;
import org.springframework.web.servlet.config.annotation.ViewControllerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * @Auther: dlh
 * @Date: 2020/12/11
 * @ClassName: MyMvcConfig
 * @Describle: 技术在灵魂面前必输
 * @Version:1.0
 **/
@Configuration
public class MyMvcConfig implements WebMvcConfigurer {

//    @Bean
//    public ViewResolver myViewResolver(){
//        return  new MyViewResolver();
//    }
//
//    //自定义一个自己的视图解析器MyViewResolver
//    public static class MyViewResolver implements ViewResolver {
//        @Nullable
//        @Override
//        public View resolveViewName(String viewName, Locale locale) throws Exception {
//            return null;
//        }
//    }
//
    @Override
    public void addViewControllers(ViewControllerRegistry registry) {
        registry.addViewController("/").setViewName("index");
        registry.addViewController("/index.html").setViewName("index");
        registry.addViewController("/main.html").setViewName("dashboard");
    }
    @Bean
    public LocaleResolver localeResolver(){
        return  new MyLocalResolver();
    }
}
